﻿using System;
using System.ComponentModel.Composition;
using System.ComponentModel.Composition.Hosting;
using System.Web.Mvc;

namespace Mvc1.App_Start
{
    public class MefBootstrapper
    {
        public void Init()
        {
            string searchPath = AppDomain.CurrentDomain.RelativeSearchPath;
            var catalog = new DirectoryCatalog(searchPath);
            var container = new CompositionContainer(catalog);
            container.ComposeParts(this);
            ControllerBuilder.Current.SetControllerFactory(new MefControllerFactory(container));
        }
    }
}